1 In the Car folder you'll find a few ready-made Car prefabs, which are used in the Car sample scenes. These prefabs demonstrate how you can use the Car scripts we've included, including some AI-controlled variants which are able to drive directly towards a specified target, or follow a waypoint-based route.
2
3 The scripts included have been designed to be modular
in nature, so that the extra features of a particular car can be set up (such as brake lights, engine sound, and skid trails).
4
5 The simplest way to
get started setting up your own car is to use our "CarPrefabEmpty", and to follow these steps:
6
7 1
) Start with a suitable scene. There ought to be enough flat ground to drive around on.
8
9 2
) Place the "CarPrefabEmpty" in the scene.
10
11 3
) Place your 3d model into the scene, as a child of the "CarPrefabEmpty" GameObject. Notice that your car model should be at the same level as the "WheelHub" objects that were already present.
12
13 4
) Make sure your car's position in the inspector is set to 0,0,0. This will ensure your car's position is aligned with the Empty Prefab's position.
14
15 5
) Expand the hierarchy of your car model in the hierarchy so that the wheel models of your car are visible.
16
17 6
) Select each "WheelHub" in turn, and drag the corresponding wheel model from your car into the "Wheel Model" slot of the Wheel component on the WheelHub GameObject. Then click the "Align to assigned wheel model". If your car has four wheels, you'll need to do this step four times, once for each wheel.
18
19 7
) Hit play, and try driving your car!
20
21 You
'll probably want to add a camera rig so that the camera follows the car as it drives off. See the Camera Rig guidelines for instructions on how to do that.
22
23 The Car script exposes a number of properties which determine the power, maximum speed, and handling of the car, however ultimately the script
is designed to provide a fun arcade game-like feel rather than attempting to be a realistic simulation of car handling. The gears and revs values are purely cosmetic, and are calculated retrospectively - they can be used by the engine sound component or GUI to display revs and gear.
24
25 For more detail about each setting, see the comments
in the script.
26
27 The CarUserControl script takes input
from the "CrossPlatformInput" class included in the sample assets, however if you're not targeting mobile or prefer to use a different system to read input, you can simply use unity's built in Input class in place of CrossPlatformInput. For more information, see the Cross Platform Input guidelines.
28
29 The sample scenes provided work
on standalone builds and also include cross platform touch and tilt controls which are set up and ready to publish to mobile.
30
31 The CarAIControl component can be added instead of the CarUserControl component, allowing the car to be AI controlled. You can
set it up to either head towards a specified target, or (by using the WaypointProgressTracker) follow a waypoint-defined route. See the WaypointCircuit guidelines for instructions.


Gõ tìm kiếm nhanh...